package yang.yu.hrm.organisation.domain;

import org.dayatang.domain.Entity;
import org.dayatang.domain.EntityRepository;
import org.dayatang.domain.InstanceFactory;

import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import java.io.Serializable;

/**
 * Created by yyang on 2016/10/7.
 */
@MappedSuperclass
public class AbstractEntity implements Entity, Serializable {

    @Id
    private Long id;

    @Version
    private int version;

    public Long getId() {
        return id;
    }

    @Override
    public boolean existed() {
        return false;
    }

    @Override
    public boolean notExisted() {
        return false;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    protected static EntityRepository getRepository() {
        return InstanceFactory.getInstance(EntityRepository.class);
    }
}
